using System;
using System.Collections.Generic;


namespace DataObjects
{
	[Serializable]
	public class CodeType: IEquatable<CodeType>
	{

		#region Private Members

		private string _code_type_id; 
		private string _code_type_name; 
		private string _free_field1; 
		private string _free_field2; 
		private string _remark; 
		private string _group_id; 		
		#endregion

		#region Constructor

		public CodeType()
		{
			_code_type_id = String.Empty; 
			_code_type_name = String.Empty; 
			_free_field1 = String.Empty; 
			_free_field2 = String.Empty; 
			_remark = String.Empty; 
			_group_id = String.Empty; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public CodeType(
			string code_type_id, 
			string code_type_name, 
			string group_id)
			: this()
		{
			_code_type_id = code_type_id;
			_code_type_name = code_type_name;
			_free_field1 = String.Empty;
			_free_field2 = String.Empty;
			_remark = String.Empty;
			_group_id = group_id;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual string CodeTypeId
		{
			get
			{ 
				return _code_type_id;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for CodeTypeId", value, "null");
				
				if(  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for CodeTypeId", value, value.ToString());
				
				_code_type_id = value;
			}
		}
			
		public virtual string CodeTypeName
		{
			get
			{ 
				return _code_type_name;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for CodeTypeName", value, "null");
				
				if(  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for CodeTypeName", value, value.ToString());
				
				_code_type_name = value;
			}
		}
			
		public virtual string FreeField1
		{
			get
			{ 
				return _free_field1;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for FreeField1", value, value.ToString());
				
				_free_field1 = value;
			}
		}
			
		public virtual string FreeField2
		{
			get
			{ 
				return _free_field2;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for FreeField2", value, value.ToString());
				
				_free_field2 = value;
			}
		}
			
		public virtual string Remark
		{
			get
			{ 
				return _remark;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Remark", value, value.ToString());
				
				_remark = value;
			}
		}
			
		public virtual string GroupId
		{
			get
			{ 
				return _group_id;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for GroupId", value, "null");
				
				if(  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for GroupId", value, value.ToString());
				
				_group_id = value;
			}
		}
			
				
		#endregion 

		#region Public Functions

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			CodeType castObj = (CodeType)obj; 
			return ( castObj != null ) &&
				( this._code_type_id == castObj.CodeTypeId );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _code_type_id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public bool Equals(CodeType other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._code_type_id == other.CodeTypeId );
				   
		}

		#endregion
		
	}
}
